﻿using System;

class Sevenland_Numbers
{
    static void Main()
    {
        int k = int.Parse(Console.ReadLine());

        if ((k % 10) == 6)
        {
            k /= 10;

            if ((k % 10) == 6)
            {
                k /= 10;

                if ((k % 10) == 6)
                {
                    Console.WriteLine(1000);
                }
                else
                {
                    Console.WriteLine((k + 1) * 100);
                }
            }
            else
            {
                Console.WriteLine((k + 1) * 10);
            }
        }
        else
        {
            Console.WriteLine(k + 1);
        }
    }
}
